<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>C++ Tutorial: Exceptions
</title>
  <meta
 content="C++ Tutorial: Exception handling"
 name="description" />
  <meta
 content="C++ Tutorial, Exception handling, Exceptions, Try, Catch, Throw"
 name="keywords" />
  <meta http-equiv="Content-Type"
 content="text/html; charset=ISO-8859-1" />
  <link type="text/css" rel="stylesheet" href="../images/bogostyleWidePre.css" />
</head>
<body>
<div id="page" align="center">
<div id="content" style="width: 800px;">
<div id="logo">
<div class="whitetitle" style="margin-top: 70px;">bogotobogo </div>
</div>
<div id="topheader">
<div class="headerbodytext" align="left"><br />
<strong>Bogotobogo</strong><br />
contact@bogotobogo.com </div>
<div class="smallgraytext" id="toplinks"><a href="../index.html">Home</a>
| <a href="../sitemap.html">Sitemap</a>
| <a href="../blog" target="_blank">Contact Us</a>
</div>
</div>
<div id="menu">
<div class="smallwhitetext" style="padding: 9px;" align="right"><a
 href="../index.html">Home</a>
| <a href="../about_us.html">About Us</a>
| <a href="../products.html">Products</a>
| <a href="../our_services.html">Our Services</a>
| <a href="../blog" target="_blank">Contact Us</a>
</div>
</div>
<div id="submenu">
<div class="smallgraytext" style="padding: 9px;" align="right">
<a href="../gif.html">Gif</a> 
|<a href="../java_applet.html">JavaApplet/Web Start</a>
| <a href="../flash.html">Flash</a>
| <a href="../shockwave.html">ShockWave</a>
| <a href="../svg.html">SVG</a>
| <a href="../iPhone.html">iPhone/iPad</a>
| <a href="../android.html">Android</a>
| <a href="../OnHTML5.html">HTML5</a>
| <a href="../Algorithms/algorithms.html">Algorithms</a>
| <a href="../News/NewsMain.html">News</a>
| <a href="../cplusplus/cpptut.html">C++</a>
| <a href="../Java/tutorial/on_java.html">Java</a>
| <a href="../php/phptut.html">PHP</a>
| <a href="../DesignPatterns/introduction.html">Design Patterns</a>
| <a href="../python/pytut.html">Python</a> 
| <a href="../CSharp/.netframework.html">C#</a>
| <a href="../forums.html">Forums</a> 
| <a href="../VisualBasicSQL/introduction.html">Visual Basic</a>
</div>
</div>

<div id="contenttext">
<br />
<!-- Use of this code assumes agreement with the Google Custom Search Terms of Service. -->
<!-- The terms of service are available at http://www.google.com/cse/docs/tos.html -->
<form name="cse" id="searchbox_demo" action="http://www.google.com/cse">
  <input type="hidden" name="cref" value="" />
  <input type="hidden" name="ie" value="utf-8" />
  <input type="hidden" name="hl" value="" />
  <input name="q" type="text" size="40" />
  <input type="submit" name="sa" value="Search" />
</form>
<script type="text/javascript" src="http://www.google.com/cse/tools/onthefly?form=searchbox_demo&lang="></script>


<br />
<div style="padding: 10px;"><span class="titletext">C++ Tutorial - Exceptions</span></div>

<div id="bookmarkshare">
<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script>
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=khhong7"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=khhong7"></script>
</div>


<img src="../images/cplusplus/cpp_logo.jpg" alt="cplusplus logo"/>

<div class="bodytext" style="padding: 12px;" align="justify"> 
<div class="subtitle_2nd" id="FullList">Full List of C++ Tutorials</div>
<ul>
   <li><a href="cpptut.html">C++ Home</a> </li>
   <li><a href="string.html">String</a> </li>
   <li><a href="constructor.html">Constructor</a> </li>
   <li><a href="operatoroverloading.html">Operator Overloading</a> </li>
   <li><a href="virtualfunctions.html">Virtual Functions</a></li>
   <li><a href="dynamic_cast.html">Dynamic Cast Operator</a></li>
   <li><a href="typecast.html">Type Cast Operators</a></li>
   <li><a href="autoptr.html">Class auto_ptr</a></li>
   <li><a href="templates.html">Templates</a></li>
   <li><a href="references.html">References for Built-in Types</a></li>
   <li><a href="valuevsreference.html">Pass by Value vs. Pass by Reference</a></li>
   <li><a href="memoryallocation.html">Memory Allocation</a></li>
   <li><a href="friendclass.html">Friend Functions and Friend Classes</a></li>
   <li><a href="functors.html">Functors (Function Objects)</a></li>
   <li><a href="statics.html">Static Variables and Static Class Members</a></li>
   <li><a href="exceptions.html">Exceptions</a></li>
   <li><a href="pointers.html">Pointers</a></li>
   <li><a href="pointers2.html">Pointers II</a></li>
   <li><a href="pointers3.html">Pointers III</a></li>
   <li><a href="assembly.html">Taste of Assembly</a></li>
   <li><a href="smallprograms.html">Small Programs</a></li>
   <li><a href="linkedlist.html">Linked List Examples</a></li>
   <li><a href="binarytree.html">Binary Tree Example Code</a></li>
   <li><a href="stl.html">Standard Template Library (STL)</a></li>
   <li><a href="stl2.html">Standard Template Library (STL) II - Maps</a></li>
   <li><a href="stl3_iterators.html">Standard Template Library (STL) III - Iterators</a></li>
   <li><a href="slicing.html">Object Slicing and Virtual Table</a></li>
   <li><a href="this_pointer.html">The this Pointer</a></li>
   <li><a href="stackunwinding.html">Stack Unwinding</a></li>
   <li><a href="upcasting_downcasting.html">Upcasting and Downcasting</a></li>
   <li><a href="object_returning.html">Object Returning</a></li>
   <li><a href="private_inheritance.html">Private Inheritance</a></li>
   <li><a href="cplusplus_keywords.html">C++_Keywords</a></li>
   <li><a href="multithreaded.html">Multi-Threaded Programming - Terminology</a></li>
   <li><a href="multithreaded2A.html">Multi-Threaded Programming II - Native Thread for Win32 (A) </a></li>
   <li><a href="multithreaded2B.html">Multi-Threaded Programming II -  Native Thread for Win32 (B) </a></li>
   <li><a href="multithreaded2C.html">Multi-Threaded Programming II -  Native Thread for Win32 (C) </a></li>
   <li><a href="multithreaded2.html">Multi-Threaded Programming II - C++ Thread for Win32</a></li>
   <li><a href="multithreaded3.html">Multi-Threaded Programming III - C++ Class Thread for Pthreads</a></li>
   <li><a href="multithreadedDebugging.html">Multithread Debugging</a></li>
   <li><a href="embeddedSystemsProgramming.html">Embedded Systems Programming</a></li>
   <li><a href="boost.html">Boost</a></li>
   <li>Programming Questions and Solutions
    <ul>
       <li><a href="quiz_strings_arrays.html">Strings and Arrays</a></li>
       <li><a href="quiz_linkedlist.html">Linked List</a></li>
       <li><a href="quiz_recursion.html">Recursion</a></li>
       <li><a href="quiz_bit_manipulation.html">Bit Manipulation</a> </li>
       <li><a href="google_interview_questions.html">140 Google Interview Questions</a> </li>
    </ul>
   </li>
</ul>
</div>

<br /><br />
<img src="images/exceptions/WanDo.png" alt="WanDo"/>
<br /><br />

<br />
<div class="bodytext" style="padding: 12px;" align="justify">

<div class="subtitle" id="exceptions">Exceptions</div>
<p>Our programs sometimes have runtime problems that prevent from running normally. A program may request more memory than is available, or it may try to open an unavailable file, or it make see values it cannot handle.</p>
<p>Exceptions provide a way to react to exceptional circumstances like the ones listed above by transferring control to special functions called handlers. Exception handling is a fundamental error reporting mechanism designed to handle the occurrence of exceptions, special conditions that change the normal execution flow of a program.</p>
<p>To catch exceptions we must place a portion of code under exception inspection. This is done by enclosing that portion of code in a try block. When an exceptional circumstance arises within that block, an exception is thrown that transfers the control to the exception handler. If no exception is thrown, the code continues normally and all handlers are ignored.</p>
<br />
<br />


<div class="subtitle" id="abort">abort() and exit()</div>
<p>The <strong>abort()</strong> function's prototype is in <strong>cstdlib</strong> header file. If called it sends a message something like "abnormal program termination" to the standard error stream and terminate the program. It may also return an implementation-dependent value that indicates failure to the operating system. Whether <strong>abort()</strong> flushes the buffers depends on the implementation. So, if you prefer, you can use <strong>exit</strong> which does flush file buffers. But <strong>exit</strong>  does not give any message as in the following examples.</p>
<p>Note that calling <strong>abort()</strong> from <strong>myCalculator</strong> terminates the program directly without returning <strong>main()</strong>. 
<pre>
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;

double myCalculator(double a, double b) {
	if(a == b) {
		cout << "abort()!" << endl;
		<font color="blue">abort();</font>
	}
	return 1 / (a - b);
}

int main () {
	double x,y,z;
	x = 10;
	y = 10;
	z = myCalculator(x,y);
	cout << "x = " << x << " y = " << y << " z = " << z << endl;
	return 0;
}
</pre>
<p>Output is:</p>
<pre>
abort()! 
</pre>
<p>and with an error message from my Visual Studio 2005: <br />
Debug Error! <br />
This application has requested the Runtime to terminate it in an unusual way.</p>
<p>If we switch the <strong>abort()</strong> to <strong>exit(1)</strong>, <br />
<pre>
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

double myCalculator(double a, double b) {
	if(a == b) {
		cout << "exit(1)!" << endl;
		<font color="blue">exit(1);</font>
	}
	return 1 / (a - b);
}

int main () {
	double x,y,z;
	x = 10;
	y = 10;
	z = myCalculator(x,y);
	cout << "x = " << x << " y = " << y << " z = " << z << endl;
	return 0;
}

</pre>
the program is terminated silently with a print out.<br />
<pre>
exit(1)!
</pre>
<p>If we run the above code without <strong>abort()</strong> or <strong>exit(1)</strong>, we get the following output.</p>
<pre>
x = 10 y = 10 z = 1.#INF
</pre>

<br />
<br />


<div class="subtitle" id="tryandcatch">try and catch</div>
<p>C++ <strong>exception</strong> is a response to an exceptional circumstance that arises while a programming is running. Exceptions provide a way to transfer control from one part of a program to another.</p>
<p>Exception handling has three components:</p>
<ul>
	<li>Throwing an exception </li>
	<li>Catching an exception with a handler </li>
	<li>Using a <strong>try</strong> block </li>
</ul>
<p>A throw statement is a <strong>jump</strong>. In other words, it tells a program to jump to statements at another location. It's followed by a value such as a character string or an object that indicates the nature of the exception.</p>
<p>Let's look at the following code:</p>
<pre>
#include &lt;iostream&gt;
using namespace std;

int main () {
  <font color="blue">try</font> {
    <font color="blue">throw</font> "Homemade exception";
  }
  <font color="blue">catch</font> (const char* e) {
	  cout << "exception: " << e << endl;
  }
  return 0;
}
</pre>
<p>Its output is:</p>
<pre>
exception: Homemade exception
</pre>
<p>The <strong>try</strong> block has the code under exception handling. It just throws an exception:<br />
<pre>
throw "Homemade exception";
</pre> 
A throw accepts one parameter which is passed as an argument to the exception handler.</p>
<p>The <strong>catch</strong> keyword declares the exception handler. It follows immediately the closing brace of the <strong>try</strong> block. The format for <strong>catch</strong> is similar to a regular function that always has at least one parameter. The type of this parameter is very important, since the type of the argument passed by the throw expression is checked against it. The exception is caught only when they match.</p>
<p>Multiple handlers (catch expressions) could be used, each one with a different parameter type. Only the handler that matches its type with the argument specified in the throw statement is executed.</p>
<p>Ellipsis (...) can be used as the parameter of <strong>catch</strong>. The handler will catch any exception no matter what the type of the <strong>throw</strong> exception is. This can be used as a default handler that catches all exceptions not caught by other handlers if it is specified at last:</p>
<pre>
#include &lt;iostream&gt;
using namespace std;

int main () {
  <font color="blue">try</font> {
    <font color="blue">throw</font> "Homemade exception";
  }
  <font color="blue">catch</font> (int e){
	  cout << "int exception: " << e << endl;
  }
  <font color="blue">catch</font> (char e){
	  cout << "char exception: " << e << endl;
  }
  <font color="blue">catch</font> (...) { 
	  cout << "default exception ";
  }
  return 0;
}
</pre>
<p>In the example, the exception is caught at:
<pre>
catch (...) 
</pre>
The exception get caught is the exception thrown with any parameter that is neither an <strong>int</strong> nor a <strong>char</strong>.</p>
<p>
After an exception has been handled the program execution resumes after the <strong>try-catch</strong> block, not after the <strong>throw</strong>.</p>
<p>How about <strong>nested</strong> try-catch blocks? <br /> 
Yes, it is also possible to nest <strong>try-catch</strong> blocks within more external <strong>try</strong> blocks. In these cases, we have the possibility that an internal <strong>catch</strong> block forwards the exception to its outer level. This is done with the expression <strong>throw</strong> with no arguments. 
</p>
<p>Here is the example: </p>
<pre>
#include &lt;iostream&gt;
using namespace std;

int main () {
  try {
	try {
		throw 911;
	}
	catch (int n) {
	  cout << "inner catch " << endl;
      throw;
	}
  }
  catch (...) {
    cout << "catching any exception occurred" << endl;
  }
  return 0;
}
</pre>
<p>The output is:</p>
<pre>
inner catch
catching any exception occurred
</pre>

<br />
<br />


<div class="subtitle" id="specification">Exception Specification</div>
<p>We can limit the exception type it might directly or indirectly throw by appending a <strong>throw</strong> suffix to the function declaration:</p>
<pre>
float f(char param) throw (int);
</pre>
<p>
This declares a function called <strong>f()</strong> which takes one argument of type <strong>char</strong> and returns an element of type <strong>float</strong>. The only exception that this function might throw is an exception of type <strong>int</strong>. If it throws an exception with a different type, either directly or indirectly, it cannot be caught by a regular <strong>int</strong>-type handler.</p>
<p>If this <strong>throw</strong> specifier is left empty with no type, this means the function is not allowed to throw exceptions. Functions with no <strong>throw</strong> specifier (regular functions) are allowed to throw exceptions with any type:</p>
<pre>
int f(int param) throw(); // no exceptions allowed
int f(int param);        // all exceptions allowed 
</pre>
<br />
<br />


<div class="subtitle" id="standard">Standard exceptions</div>
<p>The C++ Standard library provides a base class specifically designed to declare objects to be thrown as exceptions. It is called <strong>exception</strong> and is defined in the &lt;exception&gt; header file under the <strong>namespace std</strong>. This class has the usual default and copy constructors, operators and destructors, plus an additional virtual member function called <strong>what()</strong> that returns a null terminated byte string:</p>
<pre>
public exception {
public:
  virtual const char* what() const throw();
}; 
</pre>
<p>The content of the string is implementation dependent. It most likely determines the level of help and detail of such information.</p>
<p>The  member function <strong>what()</strong> can be overwritten in derived classes to contain the description of the exception.</p>
<pre>
#include &lt;iostream&gt;
#include &lt;exception&gt;
using namespace std;

class child_exception: public exception {
  virtual const char* what() const throw(){
    return "child exception occurred";
  }
}; 

int main () {
  try {
    child_exception cex;
    throw cex;
  }
  catch (exception& e) {
    cout << e.what() << endl;
  }
  return 0;
}
</pre>

<p>We have placed a handler that catches exception objects by reference (notice the ampersand & after the type), therefore this catches also classes derived from exception, like our <strong>cex</strong> object of class <strong>child_exception</strong>.</p>
<p>
All exceptions thrown by components of the C++ Standard library throw exceptions derived from this <strong>std::exception</strong> class. These are:</p>
<ul>
	<li>bad_alloc <br />
	This exception is thrown whenever the global operator <strong>new</strong> fails (except when the <strong>nothrow</strong> version of <strong>new</strong> is used). This is the most important exception because it might occur at any time in any nontrivial program. </li>
	<li>bad_cast <br />
	This exception is thrown by <strong>dynamic_cast</strong>  if a type conversion on a reference fails at runtime. </li>
	<li>bad_exception<br />
	This is used to handle unexpected exceptions. It does this by using the function <strong>unexpected()</strong>.  <strong>unexpected()</strong> is called if a function throws an exception that is not listed in an <strong>exception specification</strong>.
	For example:
<pre>
	class E1;
	class E2;
	void f() throw(E1) {	//throws only exception of type E1
		throw E1();	//throws exception of type E1
		throw E2();	//calls <strong>unexpected()</strong>, which calls <strong>terminate()</strong>
	}
</pre>
	The throw of an exception of type <strong>E2</strong> in <strong>f()</strong> violates the exception specification. In this case, the function <strong>unexpected()</strong> gets called, which usually calls <strong>terminate()</strong> to terminate the program. However, if class <strong>bad_exception</strong> is part of the exception specification, then <strong>unexpected()</strong> usually rethrows an exception of this type:<br />
<pre>
	class E1;
	class E2;
	void f() throw(E1, std::bad_exception) {	
				//throws exception of type E1 or 
				//<strong>bad_exception</strong> for any other exception type
		throw E1();	//throws exception of type E1
		throw E2();	//calls <strong>unexpected(), which throws </strong>bad_exception()</strong>
	}
</pre>
	So, if an exception specification includes the class<strong>bad_exception</strong>, then any exception not part of the specification may be replaced by <strong>bad_exception</strong> within the function <strong>unexpected()</strong>.
</li>
	<li>bad_typeid <br />
	This exception is thrown by <strong>typeid</strong>. If the argument to <strong>typeid</strong> is zero or the null pointer, this exception is thrown.  </li>
</ul>

<p>For example, if we use the operator <strong>new</strong> and the memory cannot be allocated, an exception of type <strong>bad_alloc</strong> is thrown:</p>
<pre>
#include &lt;iostream&gt;
#include &lt;exception&gt;
using namespace std;

int main () {
  try {
	long double * arr= new long double[150000000];
  }
  catch (bad_alloc&){
	cout << "Error allocating memory." << endl;
  }
  return 0;
}
</pre>
<p>
All dynamic memory allocations better be included within a try block that catches this type of exception to perform a clean action instead of an abnormal program termination. Abnormal termination happens when this type of exception is thrown and not caught. </p>
<p>The <strong>bad_alloc</strong> is derived from the standard base class <strong>exception</strong>. Thus,  we can handle that same exception by catching references to the <strong>exception</strong> class:</p>
<pre>
#include &lt;iostream&gt;
#include &lt;exception&gt;
using namespace std;

int main () {
  try{
	long double * arr= new long double[150000000];
  }
  catch (exception& e){
	cout << "Standard exception: " << e.what() << endl;
  }
  return 0;
}
</pre>

<br />
<br />


<div class="subtitle" id="exceptionsafe">Writing Exception-safe Code</div>
<p>Here is some guide lines from the book "Exceptional C++ Style" by H. Sutter.</p>
<ul>
	<li>Exception safety is rarely about writing <strong>try</strong> and <strong>catch</strong>-and the more rarely is the better.</li>
	<li>Prefer handling exception cleanup automatically by using <strong>destructor</strong> instead of <strong>try/catch</strong>.</li>
	<li>Determine an overall error reporting and handling policy for your application or subsystem, and stick to it.</li>
	<li>Write <strong>throw</strong> in the places that detect an error and cannot deal with it themselves.</li>
	<li>Write <strong>try</strong> and <strong>catch</strong> in places that have sufficient knowledge to handle the error, to translate it, or to enforce boundaries defined in the error policy (e.g., to <strong>catch(...)</strong> on subsystem boundaries or other run-time firewalls).</li>
</ul>


<br /><br />
<img src="images/exceptions/DohSolBong.png" alt="DohSolBong"/>
<br /><br />


<br /><br />
<div class="subtitle_2nd" id="FullList">Full List of C++ Tutorials</div>
<ul>
   <li><a href="cpptut.html">C++ Home</a> </li>
   <li><a href="string.html">String</a> </li>
   <li><a href="constructor.html">Constructor</a> </li>
   <li><a href="operatoroverloading.html">Operator Overloading</a> </li>
   <li><a href="virtualfunctions.html">Virtual Functions</a></li>
   <li><a href="dynamic_cast.html">Dynamic Cast Operator</a></li>
   <li><a href="typecast.html">Type Cast Operators</a></li>
   <li><a href="autoptr.html">Class auto_ptr</a></li>
   <li><a href="templates.html">Templates</a></li>
   <li><a href="references.html">References for Built-in Types</a></li>
   <li><a href="valuevsreference.html">Pass by Value vs. Pass by Reference</a></li>
   <li><a href="memoryallocation.html">Memory Allocation</a></li>
   <li><a href="friendclass.html">Friend Functions and Friend Classes</a></li>
   <li><a href="functors.html">Functors</a></li>
   <li><a href="statics.html">Static Variables and Static Class Members</a></li>
   <li><a href="exceptions.html">Exceptions</a></li>
   <li><a href="pointers.html">Pointers</a></li>
   <li><a href="pointers2.html">Pointers II</a></li>
   <li><a href="pointers3.html">Pointers III</a></li>
   <li><a href="assembly.html">Taste of Assembly</a></li>
   <li><a href="smallprograms.html">Small Programs</a></li>
   <li><a href="linkedlist.html">Linked List Examples</a></li>
   <li><a href="binarytree.html">Binary Tree Example Code</a></li>
   <li><a href="stl.html">Standard Template Library (STL)</a></li>
   <li><a href="stl2.html">Standard Template Library (STL) II - Maps</a></li>
   <li><a href="stl3_iterators.html">Standard Template Library (STL) III - Iterators</a></li>
   <li><a href="slicing.html">Object Slicing and Virtual Table</a></li>
   <li><a href="this_pointer.html">The this Pointer</a></li>
   <li><a href="stackunwinding.html">Stack Unwinding</a></li>
   <li><a href="upcasting_downcasting.html">Upcasting and Downcasting</a></li>
   <li><a href="object_returning.html">Object Returning</a></li>
   <li><a href="private_inheritance.html">Private Inheritance</a></li>
   <li><a href="cplusplus_keywords.html">C++_Keywords</a></li>
   <li><a href="multithreaded.html">Multi-Threaded Programming - Terminology</a></li>
   <li><a href="multithreaded2A.html">Multi-Threaded Programming II - Native Thread for Win32 (A) </a></li>
   <li><a href="multithreaded2B.html">Multi-Threaded Programming II -  Native Thread for Win32 (B) </a></li>
   <li><a href="multithreaded2C.html">Multi-Threaded Programming II -  Native Thread for Win32 (C) </a></li>
   <li><a href="multithreaded2.html">Multi-Threaded Programming II - C++ Thread for Win32</a></li>
   <li><a href="multithreaded3.html">Multi-Threaded Programming III - C++ Class Thread for Pthreads</a></li>
   <li><a href="multithreadedDebugging.html">Multithread Debugging</a></li>
   <li><a href="embeddedSystemsProgramming.html">Embedded Systems Programming</a></li>
   <li><a href="boost.html">Boost</a></li>
   <li>Programming Questions and Solutions
    <ul>
       <li><a href="quiz_strings_arrays.html">Strings and Arrays</a></li>
       <li><a href="quiz_linkedlist.html">Linked List</a></li>
       <li><a href="quiz_recursion.html">Recursion</a></li>
       <li><a href="quiz_bit_manipulation.html">Bit Manipulation</a> </li>
       <li><a href="google_interview_questions.html">140 Google Interview Questions</a> </li>
    </ul>
   </li>
</ul>
<br /><br />


<br />


<br />
<br />
<br />


</div>
</div>
<div class="smallgraytext" id="footer"><a href="../index.html">Home</a>
| <a href="../about_us.html">About Us</a>
| <a href="../products.html">products</a>
| <a href="../our_services.html">Our Services</a>
| <a href="#">Contact Us</a>
| Bogotobogo &copy; 2011 | <a target="_blank" href="http://www.bogotobogo.com">Bogotobogo </a>
</div>
</div>
</div>
</body>
</html>
